package cn.com.xf.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.com.xf.dao.TblRegVisitorDAO;
import cn.com.xf.dao.support.XFSqlMapClientDaoSupport;
import cn.com.xf.domain.TblRegVisitor;

@Repository
public class TblRegVisitorDAOImpl extends XFSqlMapClientDaoSupport implements TblRegVisitorDAO {

   
    public TblRegVisitorDAOImpl() {
        super();
    }

	@Override
	public List<TblRegVisitor> selectReg(TblRegVisitor trv) {
		Map<String,Object> map = new HashMap<String, Object>();
		return (List<TblRegVisitor>) getSqlMapClientTemplate().queryForList("TBL_REG_VISITOR.selectReg",trv);
	}

	@Override
	public TblRegVisitor selectById(String vid) {
		return (TblRegVisitor) getSqlMapClientTemplate().queryForObject("TBL_REG_VISITOR.selectById",vid);
	}
	
	public List<TblRegVisitor> selectIntraday(){
		return (List<TblRegVisitor>) getSqlMapClientTemplate().queryForList("TBL_REG_VISITOR.selectIntraday");
	}
	@Override
	public int vauditById(String vid) {
		return getSqlMapClientTemplate().update("TBL_REG_VISITOR.vauditById",vid);
	}


	@Override
	public int delAppointById(String vid) {
		return getSqlMapClientTemplate().update("TBL_REG_VISITOR.delAppointById",vid);
	}

	@Override
	public int outById(TblRegVisitor trv) {		
		return getSqlMapClientTemplate().update("TBL_REG_VISITOR.outById",trv);
	}

	@Override
	public void insertVisit(TblRegVisitor trv) {
		getSqlMapClientTemplate().insert("TBL_REG_VISITOR.insertVisit",trv);
		
	}

	@Override
	public int updateVisit(TblRegVisitor trv) {
		return getSqlMapClientTemplate().update("TBL_REG_VISITOR.updateVisit",trv);
	}

	@Override
	public void insertAppoint(TblRegVisitor trv) {
		getSqlMapClientTemplate().insert("TBL_REG_VISITOR.insertAppoint",trv);
		
	}

	@Override
	public int updateAppoint(TblRegVisitor trv) {
		return getSqlMapClientTemplate().update("TBL_REG_VISITOR.updateAppoint",trv);
	}

	@Override
	public int appointToVisit(TblRegVisitor trv) {
		return getSqlMapClientTemplate().update("TBL_REG_VISITOR.appointToVisit",trv);
	}
	
	public void appointToVisitCam(TblRegVisitor trv){
		getSqlMapClientTemplate().update("TBL_REG_VISITOR.appointToVisitCam",trv);
	}
	
	@Override
	public int selectCountAppoint(String staffid, String vname, String status,String vaudit,String appointtimeStart,
			String appointtimeEnd) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("staffid",staffid);
		map.put("vname",vname);
		map.put("status",status);
		map.put("vaudit",vaudit);
		map.put("appointtimeStart",appointtimeStart);
		map.put("appointtimeEnd",appointtimeEnd);
		return (Integer) getSqlMapClientTemplate().queryForObject("TBL_REG_VISITOR.selectCountAppoint",map);
	}

	@Override
	public List<TblRegVisitor> selectAppoint(int begin, int pageSize, String orderByField, String orderByMode,String staffid, String vname,
			String status,String vaudit,String appointtimeStart, String appointtimeEnd) {
		Map<String,Object> map = new HashMap<String, Object>();
		int end = begin + pageSize;
		begin = begin + 1;
		map.put("begin", begin);
		map.put("end", end);
		map.put("orderByField", orderByField);
		map.put("orderByMode", orderByMode);
		map.put("staffid",staffid);
		map.put("vname",vname);
		map.put("status",status);
		map.put("vaudit",vaudit);
		map.put("appointtimeStart",appointtimeStart);
		map.put("appointtimeEnd",appointtimeEnd);
		return (List<TblRegVisitor>) getSqlMapClientTemplate().queryForList("TBL_REG_VISITOR.selectAppoint",map);
	}

	@Override
	public int selectCountVisit(String username, String vname, String vid, String visittimeStart, String visittimeEnd) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("username",username);
		map.put("vname",vname);
		map.put("vid",vid);
		map.put("visittimeStart",visittimeStart);
		map.put("visittimeEnd",visittimeEnd);
		return (Integer) getSqlMapClientTemplate().queryForObject("TBL_REG_VISITOR.selectCountVisit",map);
	}

	@Override
	public List<TblRegVisitor> selectRegVisitor(int begin, int pageSize, String orderByField, String orderByMode,
			String username, String vname, String vid, String visittimeStart, String visittimeEnd) {
		Map<String,Object> map = new HashMap<String, Object>();
		int end = begin + pageSize;
		begin = begin + 1;
		map.put("begin", begin);
		map.put("end", end);
		map.put("orderByField", orderByField);
		map.put("orderByMode", orderByMode);
		map.put("username",username);
		map.put("vname",vname);
		map.put("vid",vid);
		map.put("visittimeStart",visittimeStart);
		map.put("visittimeEnd",visittimeEnd);
		return (List<TblRegVisitor>) getSqlMapClientTemplate().queryForList("TBL_REG_VISITOR.selectRegVisitor",map);
	}

	

}